﻿#region COPYRIGHT© 2009-2013 Phillip Clark. All rights reserved.

// For licensing information see License.txt (MIT style licensing).

#endregion

using System;
using System.Collections.Generic;

namespace FlitBit.Json
{
	public sealed class JsonMemberValue : JsonMember
	{
		public JsonMemberValue(string name, JsonValue value)
			: base(name, value)
		{}

		public override int Count { get { return 1; } }

		public override bool IsReadOnly { get { return true; } }

		public override void Add(JsonValue item)
		{
			throw new NotImplementedException();
		}

		public override void Clear()
		{
			base.Value = JsonNull.Object;
		}

		public override bool Contains(JsonValue item)
		{
			return base.Value == item;
		}

		public override void CopyTo(JsonValue[] array, int arrayIndex)
		{
			throw new NotImplementedException();
		}

		public override IEnumerator<JsonValue> GetEnumerator()
		{
			for (var i = 0; i < 1; i++)
			{
				yield return Value;
			}
		}

		public override bool Remove(JsonValue item)
		{
			if (Value == item)
			{
				Clear();
				return true;
			}
			return false;
		}
	}
}